import {ROOT_URL,ROOT_WEB_URL} from './rpc';
import {imei} from './auth'

//自动授权登录
export function WechatAuth(uri) {
    /*const newPath = ROOT_URL + "wechat/wxCode";
    const nowPath = window.location.href.split('?')[0];
    location.href = newPath + "?callBackUrl=" + nowPath + "&imei=" + imei+"&state=123";*/
    const newPath = "https://open.weixin.qq.com/connect/oauth2/authorize";
    //const redirectPath  = uri ? uri : 'http://meiyepage.tunnel.qydev.com/index';
    const redirectPath  = uri ? uri : ROOT_WEB_URL+'index';
    location.href = newPath + "?appid=wx338c70c5b964b8da&redirect_uri="+redirectPath+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
}

//分享达人自动授权登录
export function WechatShareAuth() {
    const newPath = "https://open.weixin.qq.com/connect/oauth2/authorize";
    //const redirectPath  = 'http://meiyepage.tunnel.qydev.com/shareGoodsDesc';
    const redirectPath  = ROOT_WEB_URL+'shareGoodsDesc';
    location.href = newPath + "?appid=wx338c70c5b964b8da&redirect_uri="+redirectPath+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
}

//分享商品列表自动授权登录
export function WechatShareMall() {
    const newPath = "https://open.weixin.qq.com/connect/oauth2/authorize";
    const redirectPath  = ROOT_WEB_URL+'shareMalls';
    location.href = newPath + "?appid=wx338c70c5b964b8da&redirect_uri="+redirectPath+"&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
}

